﻿package com.yy.ui.controls {
    import com.yy.ui.core.UIComponent;
    import com.yy.ui.general.VinciFont;
    
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;

    public class Label extends UIComponent {

        private var _textField:TextField;
        private var _mouseSprite:Sprite;
        private var _text:String = "";
        private var _widthAuto:Boolean = false;

        public function Label(_arg1:String="", _arg2:VinciFont=null, _arg3:Number=0){
            this.widthAuto = false;
            super.width = 100;
            super.height = 25;
            this._textField = new TextField();
            this._textField.width = this.width;
            this._textField.height = this.height;
            this._textField.selectable = false;
            this._textField.addEventListener(MouseEvent.MOUSE_OVER, this.mouseHandler);
            this._textField.addEventListener(MouseEvent.MOUSE_OUT, this.mouseHandler);
            this._textField.addEventListener(MouseEvent.MOUSE_DOWN, this.mouseHandler);
            this._textField.addEventListener(MouseEvent.MOUSE_UP, this.mouseHandler);
            this._textField.addEventListener(MouseEvent.CLICK, this.mouseHandler);
            if (_arg2){
                _arg2.apply(this._textField);
            };
            this.text = _arg1;
            this._textField.y = _arg3;
            addChild(this._textField);
            this._mouseSprite = new Sprite();
            this._mouseSprite.graphics.beginFill(39423, 0);
            this._mouseSprite.graphics.drawRect(0, 0, 10, 10);
            this._mouseSprite.graphics.endFill();
            addChild(this._mouseSprite);
        }
        private function mouseHandler(_arg1:MouseEvent):void{
            _arg1.stopPropagation();
        }
        override public function set width(_arg1:Number):void{
            this._textField.width = _arg1;
            this._mouseSprite.width = _arg1;
            super.width = _arg1;
        }
        override public function set height(_arg1:Number):void{
            this._textField.height = _arg1;
            this._mouseSprite.height = _arg1;
            super.height = _arg1;
        }
        public function get text():String{
            return (this._text);
        }
        public function set text(_arg1:String):void{
            this._textField.text = _arg1;
            if (this.widthAuto){
                this.width = (this._textField.textWidth + 10);
            };
            this._text = _arg1;
        }
        public function get textWidth():Number{
            return (this._textField.textWidth);
        }
        public function get widthAuto():Boolean{
            return (this._widthAuto);
        }
        public function set widthAuto(_arg1:Boolean):void{
            if (_arg1){
                this.width = (this._textField.textWidth + 10);
            };
            this._widthAuto = _arg1;
        }
        public function get textColor():uint{
            return (this._textField.textColor);
        }
        public function set textColor(_arg1:uint):void{
            this._textField.textColor = _arg1;
        }
        public function get textAlpha():Number{
            return (this._textField.alpha);
        }
        public function set textAlpha(_arg1:Number):void{
            this._textField.alpha = _arg1;
        }
        public function set textFilter(_arg1:Array):void{
            this._textField.filters = _arg1;
        }
        public function get textFilter():Array{
            return (this._textField.filters);
        }
        public function get textField():TextField{
            return (this._textField);
        }

    }
}